﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenTextSummarizer;
using System.IO;

namespace OTSTester
{
    class Program
    {
        static void Main(string[] args)
        {
            Test1();
            Console.Clear();
            Test2();
            Console.Clear();
            Test3();
            Console.Clear();
            Test4();
            Console.Clear();
            Test5();
            Console.Clear();
        }

        private static void Test1()
        {
            SummarizerArguments sumargs = new SummarizerArguments();
            sumargs.DictionaryLanguage = "en";
            sumargs.DisplayLines = 10;
            sumargs.DisplayPercent = 0;
            sumargs.InputFile = @"Test1.txt";
            FileInfo testFile = new FileInfo(sumargs.InputFile);
            DateTime timer = DateTime.Now;
            SummarizedDocument doc = Summarizer.Summarize(sumargs);
            Console.WriteLine("Processed In: {0} Size: {1}", DateTime.Now.Subtract(timer).TotalMilliseconds, testFile.Length);
            

            Console.WriteLine("Summary:");
            var concepts = doc.Concepts.Select(p => p + ", ");
            Console.WriteLine(string.Concat(concepts.ToArray()));

            Console.WriteLine("\nConcepts:");
            var summary = doc.Sentences.Select(p => p + "\n");
            Console.WriteLine(string.Concat(summary.ToArray()));
            Console.ReadKey();
        }

        private static void Test2()
        {
            SummarizerArguments sumargs = new SummarizerArguments();
            sumargs.DictionaryLanguage = "en";
            sumargs.DisplayLines = 0;
            sumargs.DisplayPercent = 10;
            sumargs.InputFile = @"Test2.txt";
            FileInfo testFile = new FileInfo(sumargs.InputFile);
            DateTime timer = DateTime.Now;
            SummarizedDocument doc = Summarizer.Summarize(sumargs);
            Console.WriteLine("Processed In: {0} Size: {1}", DateTime.Now.Subtract(timer).TotalMilliseconds, testFile.Length);

            Console.WriteLine("Summary:");
            var concepts = doc.Concepts.Select(p => p + ", ");
            Console.WriteLine(string.Concat(concepts.ToArray()));

            Console.WriteLine("\nConcepts:");
            var summary = doc.Sentences.Select(p => p + "\n");
            Console.WriteLine(string.Concat(summary.ToArray()));
            Console.ReadKey();
        }

        private static void Test3()
        {
            SummarizerArguments sumargs = new SummarizerArguments();
            sumargs.DictionaryLanguage = "en";
            sumargs.DisplayLines = 0;
            sumargs.DisplayPercent = 30;
            sumargs.InputFile = @"Test3.txt";
            FileInfo testFile = new FileInfo(sumargs.InputFile);
            DateTime timer = DateTime.Now;
            SummarizedDocument doc = Summarizer.Summarize(sumargs);
            Console.WriteLine("Processed In: {0} Size: {1}", DateTime.Now.Subtract(timer).TotalMilliseconds, testFile.Length);

            Console.WriteLine("Summary:");
            var concepts = doc.Concepts.Select(p => p + ", ");
            Console.WriteLine(string.Concat(concepts.ToArray()));

            Console.WriteLine("\nConcepts:");
            var summary = doc.Sentences.Select(p => p + "\n");
            Console.WriteLine(string.Concat(summary.ToArray()));
            Console.ReadKey();
        }

        private static void Test4()
        {
            SummarizerArguments sumargs = new SummarizerArguments();
            sumargs.DictionaryLanguage = "en";
            sumargs.DisplayLines = 1;
            sumargs.DisplayPercent = 0;
            sumargs.InputFile = "";
            sumargs.InputString = @"If we make a thin slice across the stem of a rapidly growing
                                    plant,--_e.g._ geranium, begonia, celery,--mount it in water, and
                                    examine it microscopically, it will be found to be made up of numerous
                                    cavities or chambers separated by delicate partitions. Often these
                                    cavities are of sufficient size to be visible to the naked eye, and
                                    examined with a hand lens the section appears like a piece of fine
                                    lace, each mesh being one of the chambers visible when more strongly
                                    magnified. These chambers are known as 'cells,' and of them the whole
                                    plant is built up.";
            //FileInfo testFile = new FileInfo(sumargs.InputFile);
            DateTime timer = DateTime.Now;
            SummarizedDocument doc = Summarizer.Summarize(sumargs);
            Console.WriteLine("Processed In: {0} Size: {1}", DateTime.Now.Subtract(timer).TotalMilliseconds, sumargs.InputString.Length);

            Console.WriteLine("Summary:");
            var concepts = doc.Concepts.Select(p => p + ", ");
            Console.WriteLine(string.Concat(concepts.ToArray()));

            Console.WriteLine("\nConcepts:");
            var summary = doc.Sentences.Select(p => p + "\n");
            Console.WriteLine(string.Concat(summary.ToArray()));
            Console.ReadKey();
        }

        private static void Test5()
        {
            SummarizerArguments sumargs = new SummarizerArguments();
            sumargs.DictionaryLanguage = "en";
            sumargs.DisplayLines = 30;
            sumargs.DisplayPercent = 0;
            sumargs.InputFile = @"Test5.txt";
            FileInfo testFile = new FileInfo(sumargs.InputFile);
            DateTime timer = DateTime.Now;
            SummarizedDocument doc = Summarizer.Summarize(sumargs);
            Console.WriteLine("Processed In: {0} Size: {1}", DateTime.Now.Subtract(timer).TotalMilliseconds, testFile.Length);

            Console.WriteLine("Summary:");
            var concepts = doc.Concepts.Select(p => p + ", ");
            Console.WriteLine(string.Concat(concepts.ToArray()));

            Console.WriteLine("\nConcepts:");
            Console.WriteLine("Sentences Count: {0}", doc.Sentences.Count());
            //var summary = doc.Sentences.Select(p => p + "\n");
            //Console.WriteLine(string.Concat(summary.ToArray()));
            Console.ReadKey();
        }

    }
}
